package com.newenergy.wisehome.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.newenergy.wisehome.R;
import com.newenergy.wisehome.data.bean.Family;

import java.util.List;

/**
 * Created by jnl on 2017/9/14.
 */

public class ShareAdapter extends RecyclerArrayAdapter<Family> {

    public void refreshData(List<Family> data) {
        clear();
        addAll(data);
        notifyDataSetChanged();
    }

    public ShareAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int
            viewType) {
        return new ViewHolder(parent);
    }

    private class ViewHolder extends BaseViewHolder<Family> {

        private TextView tvName;
        private ImageView ivStatus;


        public ViewHolder(ViewGroup parent) {
            super(parent, R.layout.list_framily);
            tvName = $(R.id.tv_name);
            ivStatus = $(R.id.iv_status);
        }


        /*二维码*/
        @Override
        public void setData(Family data) {
            super.setData(data);
            tvName.setText(data.getName());
            ivStatus.setVisibility(data.isChecked() ? View.VISIBLE
                    : View.GONE);
        }
    }
}
